package com.ninong.ker.admin.filter;

import com.ninong.ker.admin.conf.CmdAdminInterceptor;
import com.ninong.ker.admin.conf.FilterProperties;
import com.ninong.ker.common.auth.SecurityAdmin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


/**
 * 
 * @author cmd
 *
 */
@Configuration
@EnableConfigurationProperties({ FilterProperties.class })
public class WebConfig implements WebMvcConfigurer { 
	
	@Autowired
	private SecurityAdmin securityAdmin;
	
	@Autowired
	private FilterProperties filterProperties;

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		// 自定义拦截器，添加拦截路径和排除拦截路径
		registry.addInterceptor(new CmdAdminInterceptor(securityAdmin,filterProperties)).addPathPatterns("/cmd/**");
	}
}

